home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dskut / dfa13.zip / MONMEM.PAS < prev   
Pascal/Delphi Source File  |  1986-11-19  |  2KB  |  116 lines

  1.  
  2. (*
  3.  * monmem - monitor a memory location
  4.  *
  5.  * s.h.smith, 18-nov-86
  6.  *
  7.  *)
  8.  
  9. {$i \shs\tools\regpack.inc}
  10. {$i \shs\tools\givetime.inc}
  11.  
  12. type
  13.    string2 = string[2];
  14.    string4 = string[4];
  15.    anystring = string[80];
  16.  
  17. var
  18.    screen_image: array[1..25] of anystring;
  19.  
  20.  
  21. procedure displn(s:anystring);
  22. begin
  23.    if screen_image[wherey] <> s then
  24.    begin
  25.       screen_image[wherey] := s;
  26.       write(s);
  27. {     give_up_time; }
  28.    end;
  29.    writeln;
  30. end;
  31.  
  32.  
  33. function hex2(b: byte): string2;
  34.    function hex1(b:byte): char;
  35.    begin
  36.       b := b and 15;
  37.       if b > 9 then b := b + 7;
  38.       hex1 := chr(b+ord('0'));
  39.    end;
  40. begin
  41.    hex2 := hex1(b shr 4) + hex1(b);
  42. end;
  43.  
  44.  
  45. function hex4(i:integer): string4;
  46. begin
  47.    hex4 := hex2(hi(i)) + hex2(lo(i));
  48. end;
  49.  
  50.  
  51.  
  52. procedure dump_memory(segment,offset: integer);
  53. type
  54.    byte16 = array[1..16] of byte;
  55.    byteptr = ^byte16;
  56. var
  57.    dat: byteptr;
  58.    i:   integer;
  59.    s:   anystring;
  60.  
  61. begin
  62.    dat := ptr(segment,offset);
  63.  
  64.    s := hex4(segment)+':'+hex4(offset)+' ';
  65.    for i := 1 to 16 do
  66.       s := s + ' '+hex2(dat^[i]);
  67.  
  68.    s := s + '  ';
  69.    for i := 1 to 16 do
  70.       case dat^[i] of
  71.          32..255:
  72.             s := s + chr(dat^[i]);
  73.          else
  74.             s := s + '.';
  75.       end;
  76.  
  77.    displn(s);
  78. end;
  79.  
  80.  
  81.  
  82. procedure dump_range;
  83. var
  84.    segment,offset: integer;
  85.    i:              integer;
  86.  
  87. begin
  88.    segment := $7995;
  89.    offset := $100;
  90.    for i := 1 to 6 do
  91.    begin
  92.       dump_memory(segment,offset);
  93.       offset := offset + 16;
  94.    end;
  95. end;
  96.  
  97.  
  98. procedure init;
  99. var
  100.    i: integer;
  101. begin
  102.    clrscr;
  103.    for i := 1 to 25 do
  104.       screen_image[i] := '';
  105. end;
  106.  
  107.  
  108. begin
  109.    init;
  110.    repeat
  111.       gotoxy(1,2);
  112.       dump_range;
  113.       give_up_time;
  114.    until keypressed;
  115. end.
  116.